{extend name='table'}

{block name="content"}
<div class="layui-tab layui-tab-card">
    <div class="layui-tab-content">
        {include file='country/index_search'}
        <table id="BaseTable" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
    </div>
</div>
{/block}

{block name='script'}
<script>
    $(function () {
        // 初始化表格组件
        $('#BaseTable').layTable({
            even: true, height: 'full',
            // sort: {field: 'id', type: 'desc'},
            cols: [[
                // {checkbox: true, fixed: true},
                {field: 'country_code', title: '{:lang("代码")}', align: 'center'},
                {field: 'iso_e', title: '{:lang("英文简称")}', align: 'center'},
                {field: 'coun_c_name', title: '{:lang("中文名称")}', align: 'center'},
                {field: 'coun_e_name', title: '{:lang("英文名称")}', align: 'center'},
                {field: 'high_low', title: '{:lang("税率标记")}', align: 'center'},
                {field: 'tds_high_low', title: '{:lang("船舶吨税优/普标记")}', align: 'center'},
                {field: 'iso_alpha2', title: '{:lang("ISO alpha2简称")}', align: 'center'},
                {field: 'iso_code', title: '{:lang("ISO 国家码")}', align: 'center'},
                {toolbar: '#toolbar', align: 'center', width: 120, title: '{:lang("数据操作")}', fixed: 'right'},
            ]]
        });

        // 数据状态切换操作
        layui.form.on('switch(StatusSwitch)', function (obj) {
            var data = {id: obj.value, status: obj.elem.checked ? 1 : 2};
            $.form.load("{:url('state')}", data, 'post', function (ret) {
                if (ret.code < 1) $.msg.error(ret.info, 3, function () {
                    $('#BaseTable').trigger('reload');
                }); else {
                    $('#BaseTable').trigger('reload')
                }
                return false;
            }, false);
        });


    });
</script>

<!-- 数据操作工具条模板 -->
<script type="text/html" id="toolbar">
    <!--{if auth('edit')}-->
    <a class="layui-btn  layui-btn-xs"  data-offset = "525px,240px"  data-event-dbclick data-title="{:lang('编辑数据')}" data-modal='{:url("edit")}?id={{d.id}}'>{:lang('编 辑')}</a>
    <!--{/if}-->

    <!--{if auth("remove")}-->
    <a class="layui-btn layui-btn-danger layui-btn-xs" data-confirm="{:lang('确定要删除数据吗?')}" data-action="{:url('remove')}" data-value="id#{{d.id}}">{:lang('删 除')}</a>
    <!--{/if}-->
</script>
{/block}